import pandas as pd

# 读取Excel文件
df = pd.read_excel(r'D:\荆州2022-2024转供电费用清单（线路维护中心）.xlsx')

# 转换日期格式
df['缴费起始日期'] = pd.to_datetime(df['缴费起始日期'], errors='coerce')
df['缴费结束日期'] = pd.to_datetime(df['缴费结束日期'], errors='coerce')

# 按缴费起始日期排序
df = df.sort_values(by='缴费起始日期')

# 检查日期连续性
discontinuous_meters = set()

# 按电表编码分组检查
for meter_id, group in df.groupby('缴费电表编码'):
    group = group.sort_values('缴费起始日期')  # 确保组内已排序
    for i in range(len(group)-1):
        current_end = group.iloc[i]['缴费结束日期']
        next_start = group.iloc[i+1]['缴费起始日期']
        
        # 检查是否连续（结束日期+1天=开始日期）
        if (current_end + pd.DateOffset(days=1)) != next_start:
            discontinuous_meters.add(meter_id)

# 打印结果
print("不连续缴费的电表编码：")
for meter in discontinuous_meters:
    print(meter)